<?php


class Data_Model_ChuDeMapper extends \Data_Model_DataMapperAbstract {
	protected static $_instance = null;
	// dung de phan trang
	private $_paginator = null;
	
	public function chudeList()
	{
		$db = $this->getDb();
		$selectChude = $db->select()
		->from('tbl_chude');
		$chudes = $db->fetchAll($selectChude);
		
		$chudeObjArray = array();
		foreach($chudes as $chude)
		{
			$chudeObjArray[] = $this->_populate($chude);
				
		}
		return $chudeObjArray;
	}
	/* (non-PHPdoc)
	 * @see Data_Model_DataMapperAbstract::_insert()
	 */protected function _insert(Data_Model_DomainObjectAbstract $obj) {
		// TODO Auto-generated method stub
			$db = $this->getDb();
			$data = array(
					'TenChuDe' => $obj->getTenchude()	
			);
			$db->insert('tbl_chude',$data);
		}

	/* (non-PHPdoc)
	 * @see Data_Model_DataMapperAbstract::_update()
	 */protected function _update(Data_Model_DomainObjectAbstract $obj) {
		// TODO Auto-generated method stub
		
				$db = $this->getDb();
				$data = array(
						'TenChuDe' => $obj->getTenchude()	
				);
				$where = $db->quoteInto('MaChuDe = ?',$obj->getId());
				$db->update('tbl_chude',$data,$where);
		}

	/* (non-PHPdoc)
	 * @see Data_Model_DataMapperAbstract::_populate()
	 */protected function _populate($data) {
		// TODO Auto-generated method stub
			$obj = new Data_Model_ChuDe();
			$obj->setId($data['MaChuDe']);
			$obj->setTenchude($data['TenChuDe']);
			return $obj;
		}

		public function delete($id)
		{
			$db = $this->getDb();
			$where = $db->quoteInto('MaChuDe = ?',$id);
			$db->delete('tbl_chude',$where);
		}
		
		// Goi chinh no
		
		public static function getInstance()
		{
			if(null === self::$_instance)
			{
				self::$_instance = new self();
			}
			return self::$_instance;
		}
}

?>